package org.cheetahworkflow.engine;

/**
 * workflow node entry for sequence node
 * @author caseylai
 * @param <T> context
 */
public class SequenceNodeEntry<T> implements WorkflowNodeEntry<T> {

	protected WorkflowConfigure<T> config;
	
	protected WorkflowNode<T> node;
	
	protected String nextNodeName;

	protected SequenceNodeEntry(WorkflowConfigure<T> config, WorkflowNode<T> node, String nextNodeName) {
		this.config = config;
		this.node = node;
		this.nextNodeName = nextNodeName;
	}
	
	/**
	 * execute the current workflow node and return next node
	 * @throws Exception any exception thrown from the internal logic
	 */
	@Override
	public WorkflowNodeEntry<T> exec(T context) throws Exception {
		node.exec(context);
		return config.getEntry(nextNodeName);
	}
}
